package View;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JTextPane;

import java.awt.Font;

import javax.swing.JComboBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.AbstractAction;

import java.awt.event.ActionEvent;

import javax.swing.Action;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JList;

public class NewProductToCatalogView extends JFrame {
	JLabel ProductName;
	JLabel ProductPrice;
	JLabel ProductPicture;
	JLabel ProductDescription;
	JLabel ProductID;
	JTextField IDField;
	JTextField NameField;
	JTextField PriceField;
	JTextField DescriptionField;
	JComboBox Picturebox;
	JButton SubmitButton;
	JButton BackButton;
	private final Action action = new SwingAction();
	
	public NewProductToCatalogView() {
		getContentPane().setLayout(null);
		
		setTitle("Enter New Product");
		setSize(430,452);
		
		
		ProductID = new JLabel("Product ID");
		ProductID.setFont(new Font("Tahoma", Font.PLAIN, 13));
		ProductID.setBounds(24, 53, 73, 14);
		getContentPane().add(ProductID);
		
		ProductName = new JLabel("Name");
		ProductName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		ProductName.setBounds(24, 81, 89, 14);
		getContentPane().add(ProductName);
		
		ProductPrice = new JLabel("Price");
		ProductPrice.setFont(new Font("Tahoma", Font.PLAIN, 13));
		ProductPrice.setBounds(24, 111, 73, 14);
		getContentPane().add(ProductPrice);
		
		ProductPicture = new JLabel("Picture");
		ProductPicture.setFont(new Font("Tahoma", Font.PLAIN, 13));
		ProductPicture.setBounds(24, 147, 46, 14);
		getContentPane().add(ProductPicture);
		
		ProductDescription = new JLabel("Description");
		ProductDescription.setFont(new Font("Tahoma", Font.PLAIN, 13));
		ProductDescription.setBounds(24, 182, 89, 14);
		getContentPane().add(ProductDescription);
		
		IDField = new JTextField();
		IDField.setBounds(129, 51, 147, 20);
		getContentPane().add(IDField);
		IDField.setColumns(10);
		
		NameField = new JTextField();
		NameField.setBounds(129, 79, 147, 20);
		getContentPane().add(NameField);
		NameField.setColumns(10);
		
		PriceField = new JTextField();
		PriceField.setBounds(129, 109, 149, 20);
		getContentPane().add(PriceField);
		PriceField.setColumns(10);
		
		DescriptionField = new JTextField();
		DescriptionField.setBounds(115, 182, 218, 177);
		getContentPane().add(DescriptionField);
		DescriptionField.setColumns(10);
		
		SubmitButton = new JButton("Submit");
		SubmitButton.setBounds(115, 370, 89, 23);
		getContentPane().add(SubmitButton);
		
		BackButton = new JButton("Back");
		BackButton.setBounds(244, 370, 89, 23);
		getContentPane().add(BackButton);
		
		Picturebox= new JComboBox();
		Picturebox.setBounds(129, 145, 143, 20);
		getContentPane().add(Picturebox);
	}
	private class SwingAction extends AbstractAction {
		public SwingAction() {
			putValue(NAME, "SwingAction");
			putValue(SHORT_DESCRIPTION, "Some short description");
		}
		public void actionPerformed(ActionEvent e) {
		}
	}
	
	public void showWindow(){
		setVisible(true);
	}
	public void hideWindow(){
		setVisible(false);
	}	
	public String getProductID(){
		return IDField.getText();
	}	
	public String getProductName(){
		return NameField.getText();
	}	
	public String getProductPrice(){
		return PriceField.getText();
	}
	public String getProductDescription(){
		return DescriptionField.getText();
	}
	public boolean getProductPicture(){
		if(Picturebox.getVerifyInputWhenFocusTarget()==true)
			return true;
		return false;
	}
	public  JButton getSubmitButton() {
		return SubmitButton;
	}
	public  JButton getBackBtn() {
		return BackButton;
	}
	
	public void clearFields()
	{
		IDField.setText(" ");
		NameField.setText(" ");
		PriceField.setText(" ");
		DescriptionField.setText(" ");
		Picturebox.setSelectedItem(" ");
		
	}
	public void addNewProductToCatalogListener(ActionListener actionListener)
	{
		SubmitButton.addActionListener(actionListener);
		BackButton.addActionListener(actionListener);
	}
}